
<?
if (!defined("_GNUBOARD_")) exit; // 개별 페이지 접근 불가 
include_once "_common.php";
include_once("config.php"); 

/*
    $s_page 는 cart.php 일때 수량의 수정, 물품의 삭제를 위한 변수이다.
               orderinquiryview.php 일때 배송상태등을 나타내는 변수이다.

    $s_on_uid 는 유일한 키인데 orderupdate.php 에서 ck_on_uid 를 죽이면서
    ck_tmp_on_uid 에 복사본을 넣어준다. ck_tmp_on_uid 는 orderconfirm.php 에서만 사용한다.
*/

//주문 관련 정보를 가져온다.


$colspan = 6;

?>
<style>
.amount { color:#2266BB; font-weight:bold; font-family:Verdana; } 
.c1 { background-color:#3fb193; } 
.c2 { background-color:#EEEEEE; } 
.write_head { height:30px; text-align:center; color:#8492A0; }
</style>
<table width=98% cellpadding=0 cellspacing=0 align=center style="border:1px solid #ddd; height:34px; background:url(<?=$board_skin_path?>/img/title_bg.gif) repeat-x;">
<colgroup width=80>
<colgroup width=''>
<colgroup width=80>
<colgroup width=100>
<colgroup width=100>
<colgroup width=80>
<? if ($colspan == 7) echo '<colgroup width=50>'; ?>
<tr align=center>
    <td colspan=2>상품명</td>
    <td>수량</td>
    <td>판매가</td>
    <td>소계</td>
    <td>상태</td>
<?
if ($s_page == 'cart.php')
    echo '<td>삭제</td>';
else if ($s_page == 'orderinquiryview.php')
    echo '<td>상태</td>';
?>
</tr>
</table>

<table width=98% cellpadding=0 cellspacing=0 border=0 align=center>
<colgroup width=80>
<colgroup width=''>
<colgroup width=80>
<colgroup width=100>
<colgroup width=100>
<colgroup width=80>
<?
$tot_point = 0;
$tot_sell_amount = 0;
$total_price = 0;
$tot_cancel_amount = 0;

$goods = $goods_it_id = "";
$goods_count = -1;

$sql = " select a.oi_id, a.od_id, a.it_name, a.bo_table, a.on_uid, a.wr_id, a.od_qty, a.od_price 
		 from $g4[order_item_table] a
         where a.od_id = '$od_id'
         order by a.oi_id asc";

$result = sql_query($sql);

for ($i=0; $row=mysql_fetch_array($result); $i++) {
	$item_table = $g4["write_prefix"].$row["bo_table"];
    if (!$goods) {
        $goods = addslashes($row[it_name]);
        $goods_it_id = $row[wr_id];
    }
    $goods_count++;

	$a1 = "";
	$a2 = "";
	$thumb = get_it_image($row[bo_table], $row[wr_id]."_s", 50, 50, $row[wr_id]);

	$img = "<img src='$thumb' width='50', height='50' border=0 align=left style='margin-right:5px; border:1 #222222 solid;'>";

    $it_name = $a1 . stripslashes($row[it_name]) . $a2 . "<br>";
 	$point       = $row[wr_point] * $row[od_qty];
	$sell_amount = $row[od_price] * $row[od_qty];

    if ($i > 0)
        echo "<tr><td colspan='$colspan' height=1 bgcolor=#E7E9E9></td></tr>";
                                       
	echo "<tr>";
    echo "<td align=left style='padding:5px;'>$img</td><td>";
    echo $it_name;
    echo "</td>";
	echo "<td align=center>".$row[od_qty]."</td>";
    echo "<td align=center>" . number_format($row[od_price]) . "</td>";
    echo "<td align=center>" . number_format($sell_amount) . "</td>";
    switch($od['od_status']) {
			case "쇼핑" : $icon = "<img src='./img/status01.gif'>"; break;
            case "주문" : $icon = "<img src='./img/status01.gif'>"; break;
            case "준비" : $icon = "<img src='./img/status02.gif'>"; break;
            case "배송" : $icon = "<img src='./img/status03.gif'>"; break;
            case "완료" : $icon = "<img src='./img/status04.gif'>"; break;
            default     : $icon = $od[od_status]; break;
    }
	echo "<td align=center>$icon</td>";
    echo "</tr>";
    echo "<tr><td colspan='$colspan' class=dotline></td></tr>";

	$tot_point       += $point;
	$tot_sell_amount += $sell_amount;
}

if ($goods_count)  $goods .= " 외 {$goods_count}건";

if ($i == 0) {
    echo "<tr>";
    echo "<td colspan='$colspan' align=center height=100><span class=textpoint>구매내역이 없습니다.</span></td>";
    echo "</tr>";
} else {
   
    $tot_amount = $tot_sell_amount + $send_cost;

    echo "</table>";
    echo "<table width=98% cellpadding=0 cellspacing=0 border=0 align=center style='border:1px solid #ddd; height:34px; background:url({$board_skin_path}/img/title_bg.gif) repeat-x;'>";
    echo "<tr align=center height=28>";
    echo "<td colspan=4 align=right><b>총계 : </b><span class=amount><b>" . number_format($tot_amount) . "</b></span> 원&nbsp;&nbsp;&nbsp;포인트 : " . number_format($tot_point) . "&nbsp;</td>";
    if ($s_page == "cart.php" || $s_page == "orderinquiryview.php") 
        echo "<td> &nbsp;</td>";
    echo "</tr>";
}
?>
</table>
<table width=98% cellpadding=0 cellspacing=0 align=center>
<tr> 
	<td height="5"></td>
</tr>
<tr>
  <td colspan="6" align="right">
	<div align=right><img src='./img/status01.gif' align=absmiddle> : 주문대기, <img src='./img/status02.gif' align=absmiddle> : 상품준비중, <img src='./img/status03.gif' align=absmiddle> : 배송중, <img src='./img/status04.gif' align=absmiddle> : 배송완료</div>
  </td>
</tr>
</table>